<template>
    <!--商品详情弹框-->
    <el-dialog
            title="商品详情管理"
            :visible.sync="dialogVisible"
            width="70%"
            :before-close="handleClose">
        <wangeditor :key="key" ref="editor" @change="wangeditorChange" :val="text"></wangeditor>
        <span slot="footer" class="dialog-footer">
            <el-button type="primary" @click="save()">保 存</el-button>
        </span>
    </el-dialog>
</template>

<script>
    import * as u from '@/util/util'
    export default {
        name: "info",
        components: {
            'wangeditor': () => import('@/components/wangeditor/index.vue'),
        },
        data() {
            return {
                //key
                key:u.uuid(),
                //商品id
                id: "",
                //详细内容
                text:"",
                //弹框标识
                dialogVisible: false,
            }
        },
        methods: {
            //保存
            save(){
                this.$confirm('是否确认保存?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(res=>{
                    this.$HttpService.put("/info-goods/updateInfo",{
                        id:this.id,
                        text:this.text,
                    }).then(res=>{
                        this.$message.success('保存成功');
                    })
                })

            },

            //富文本编辑器回调
            wangeditorChange(data){
                //设置线上简历
                this.text=data.html;
            },
            //打开弹框
            openDia(id) {
                this.$HttpService.get("/info-goods/get-by-id/"+id).then(res=>{
                    this.id = id;
                    this.text=res.text;
                    this.key=u.uuid();
                    this.dialogVisible = true;
                })

            },

            //关闭弹框
            handleClose(done) {
                done();
            }
        }
    }
</script>

<style scoped>

</style>
